package top.drinyeit.weilong.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

import top.drinyeit.weilong.R;
import top.drinyeit.weilong.activity.SearchActivity;
import top.drinyeit.weilong.base.LazyFragment;
import top.drinyeit.weilong.presenter.ClassificationPresenter;
import top.drinyeit.weilong.view.CarouselView;

/**
 * Created by Administrator on 2017/11/10.
 */

public class ClassificationFragment extends LazyFragment {

    private ImageView menu_search;
    public ImageView carouselView;
    private LinearLayout fruit;//水果鲜疏
    public SwipeRefreshLayout swipeRefreshLayout;
    public RecyclerView mRecyclerView;
    private ClassificationPresenter classificationPresenter;
    @Override
    protected int attachLayoutRes() {
        return R.layout.frag_classification;
    }

    @Override
    protected void initViews() {
        menu_search = mRootView.findViewById(R.id.iv_menu_search);
        carouselView = mRootView.findViewById(R.id.iv_classification_img);
        mRecyclerView = mRootView.findViewById(R.id.mRecyclerView);
        swipeRefreshLayout = mRootView.findViewById(R.id.srl_classification);
        initListener();
        initRefresh();

        setTitle(false,"分类");
    }

    @Override
    protected void lazyLoad() {
        classificationPresenter = new ClassificationPresenter(this);
        classificationPresenter.getCla();
    }

    private void initListener() {
        //搜索按钮
        menu_search.setVisibility(View.VISIBLE);
        menu_search.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(getActivity(), SearchActivity.class);
                startActivity(intent);
            }
        });

    }

    private void initRefresh(){
        swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                classificationPresenter.getCla();
            }
        });
    }

}
